/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "Hops")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Hops.findAll", query = "SELECT h FROM Hops h"),
    @NamedQuery(name = "Hops.findByHid", query = "SELECT h FROM Hops h WHERE h.hid = :hid"),
    @NamedQuery(name = "Hops.findByHopName", query = "SELECT h FROM Hops h WHERE h.hopName = :hopName"),
    @NamedQuery(name = "Hops.findByHopAA", query = "SELECT h FROM Hops h WHERE h.hopAA = :hopAA"),
    @NamedQuery(name = "Hops.findByHopWhole", query = "SELECT h FROM Hops h WHERE h.hopWhole = :hopWhole"),
    @NamedQuery(name = "Hops.findByHopBagLbs", query = "SELECT h FROM Hops h WHERE h.hopBagLbs = :hopBagLbs"),
    @NamedQuery(name = "Hops.findByHopOnHand", query = "SELECT h FROM Hops h WHERE h.hopOnHand = :hopOnHand"),
    @NamedQuery(name = "Hops.findByHopSpoken", query = "SELECT h FROM Hops h WHERE h.hopSpoken = :hopSpoken"),
    @NamedQuery(name = "Hops.findByHopOnOrder", query = "SELECT h FROM Hops h WHERE h.hopOnOrder = :hopOnOrder"),
    @NamedQuery(name = "Hops.findByHopMinimum", query = "SELECT h FROM Hops h WHERE h.hopMinimum = :hopMinimum"),
    @NamedQuery(name = "Hops.findByHopCost", query = "SELECT h FROM Hops h WHERE h.hopCost = :hopCost")})
public class Hops implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "HID")
    private Integer hid;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 80)
    @Column(name = "HopName")
    private String hopName;
    @Basic(optional = false)
    @NotNull
    @Column(name = "HopAA")
    private float hopAA;
    @Basic(optional = false)
    @NotNull
    @Column(name = "HopWhole")
    private boolean hopWhole;
    @Basic(optional = false)
    @NotNull
    @Column(name = "HopBagLbs")
    private float hopBagLbs;
    @Basic(optional = false)
    @NotNull
    @Column(name = "HopOnHand")
    private float hopOnHand;
    @Basic(optional = false)
    @NotNull
    @Column(name = "HopSpoken")
    private float hopSpoken;
    @Basic(optional = false)
    @NotNull
    @Column(name = "HopOnOrder")
    private float hopOnOrder;
    @Basic(optional = false)
    @NotNull
    @Column(name = "HopMinimum")
    private float hopMinimum;
    @Basic(optional = false)
    @NotNull
    @Column(name = "hopCost")
    private float hopCost;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "hopID")
    private Collection<HopContract> hopContractCollection;
    @OneToOne
    @JoinTable(
        name="JTHopToStock",
        joinColumns={ @JoinColumn(name="HID", referencedColumnName="HID", unique=true)},
        inverseJoinColumns={ @JoinColumn(name="StockID", referencedColumnName="StockID", unique=true)}
    )
    private StockCode stockCode;
    @OneToMany(mappedBy = "hopID")
    private Collection<BoilHops> boilHopCollection;
    @OneToMany(mappedBy = "hopID")
    private Collection<DryHops> drylHopCollection;
    @OneToMany(mappedBy = "hopID")
    private Collection<BoilHopNotes> boilHopNoteCollection;
    @OneToMany(mappedBy = "hopID")
    private Collection<DryHopNotes> dryHopNoteCollection;

    public Hops() {
    }

    public Hops(Integer hid) {
        this.hid = hid;
    }

    public Hops(Integer hid, String hopName, float hopAA, boolean hopWhole, float hopBagLbs, float hopOnHand, float hopSpoken, float hopOnOrder, float hopMinimum, float hopCost) {
        this.hid = hid;
        this.hopName = hopName;
        this.hopAA = hopAA;
        this.hopWhole = hopWhole;
        this.hopBagLbs = hopBagLbs;
        this.hopOnHand = hopOnHand;
        this.hopSpoken = hopSpoken;
        this.hopOnOrder = hopOnOrder;
        this.hopMinimum = hopMinimum;
        this.hopCost = hopCost;
    }

    public Integer getHid() {
        return hid;
    }

    public void setHid(Integer hid) {
        this.hid = hid;
    }

    public String getHopName() {
        return hopName;
    }

    public void setHopName(String hopName) {
        this.hopName = hopName;
    }

    public float getHopAA() {
        return hopAA;
    }

    public void setHopAA(float hopAA) {
        this.hopAA = hopAA;
    }

    public boolean getHopWhole() {
        return hopWhole;
    }

    public void setHopWhole(boolean hopWhole) {
        this.hopWhole = hopWhole;
    }

    public float getHopBagLbs() {
        return hopBagLbs;
    }

    public void setHopBagLbs(float hopBagLbs) {
        this.hopBagLbs = hopBagLbs;
    }

    public float getHopOnHand() {
        return hopOnHand;
    }

    public void setHopOnHand(float hopOnHand) {
        this.hopOnHand = hopOnHand;
    }

    public float getHopSpoken() {
        return hopSpoken;
    }

    public void setHopSpoken(float hopSpoken) {
        this.hopSpoken = hopSpoken;
    }

    public float getHopOnOrder() {
        return hopOnOrder;
    }

    public void setHopOnOrder(float hopOnOrder) {
        this.hopOnOrder = hopOnOrder;
    }

    public float getHopMinimum() {
        return hopMinimum;
    }

    public void setHopMinimum(float hopMinimum) {
        this.hopMinimum = hopMinimum;
    }

    public float getHopCost() {
        return hopCost;
    }

    public void setHopCost(float hopCost) {
        this.hopCost = hopCost;
    }

    public StockCode getStockCode() {
        return stockCode;
    }

    public void setStockCode(StockCode stockCode) {
        this.stockCode = stockCode;
    }

    @XmlTransient
    public Collection<HopContract> getHopContractCollection() {
        return hopContractCollection;
    }

    public void setHopContractCollection(Collection<HopContract> hopContractCollection) {
        this.hopContractCollection = hopContractCollection;
    }

    @XmlTransient
    public Collection<BoilHops> getBoilHopCollection() {
        return boilHopCollection;
    }

    public void setBoilHopCollection(Collection<BoilHops> boilHopCollection) {
        this.boilHopCollection = boilHopCollection;
    }

    @XmlTransient
    public Collection<DryHops> getDrylHopCollection() {
        return drylHopCollection;
    }

    public void setDrylHopCollection(Collection<DryHops> drylHopCollection) {
        this.drylHopCollection = drylHopCollection;
    }

    @XmlTransient
    public Collection<BoilHopNotes> getBoilHopNoteCollection() {
        return boilHopNoteCollection;
    }

    public void setBoilHopNoteCollection(Collection<BoilHopNotes> boilHopNoteCollection) {
        this.boilHopNoteCollection = boilHopNoteCollection;
    }

    @XmlTransient
    public Collection<DryHopNotes> getDryHopNoteCollection() {
        return dryHopNoteCollection;
    }

    public void setDryHopNoteCollection(Collection<DryHopNotes> dryHopNoteCollection) {
        this.dryHopNoteCollection = dryHopNoteCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (hid != null ? hid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Hops)) {
            return false;
        }
        Hops other = (Hops) object;
        if ((this.hid == null && other.hid != null) || (this.hid != null && !this.hid.equals(other.hid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.Hops[ hid=" + hid + " ]";
    }
    
}
